<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/16 0016
 * Time: 上午 10:44
 */
namespace app\admin\model;

use think\Model;

class StoreGoodsList extends Model{
    public function storeGoods(){
        return $this->belongsTo('StoreGoods','goods_id','id');
    }

    public static function goodsdetail($id,$field=['*']){
        $db = self::with('storeGoods')->find($id);
        return $db->visible($field)->toArray();
    }

    public static function reStock($data=[]){
        if (!empty($data)){
            foreach ($data as $v){
                self::where('id',$v['id'])->setDec('goods_sale',$v['goods_sale']);
            }
            return true;
        }else{
            return false;
        }
    }
}